package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.MonthlySalesDataEntity;

/**
 * 单月票房适配器
 * Created by admin on 2016/10/13.
 */

public class MonthlySalesAdapter extends RecyclerView.Adapter<MonthlySalesAdapter.ViewHolder> {
    private Context context;
    private MonthlySalesDataEntity monthlySalesDataEntity;

    public MonthlySalesAdapter(Context context, MonthlySalesDataEntity monthlySalesDataEntity) {
        this.context = context;
        this.monthlySalesDataEntity = monthlySalesDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_monthlysales, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_moviename_monthlysales.setText("电影名：  " + monthlySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieName());
        holder.tv_releasetime_monthlysales.setText("上映时间：" + monthlySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getReleaseTime());
        holder.tv_days_monthlysales.setText("上映天数：" + monthlySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getDays());
        holder.tv_boxoffice_monthlysales.setText("票房总计：" + monthlySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getBoxoffice());
    }

    @Override
    public int getItemCount() {
        return monthlySalesDataEntity.getShowapi_res_body().getDatalist().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_moviename_monthlysales;// 电影名
        private TextView tv_releasetime_monthlysales;// 上映时间
        private TextView tv_days_monthlysales;// 上映天数
        private TextView tv_boxoffice_monthlysales;// 票房总计


        public ViewHolder(View itemView) {
            super(itemView);
            tv_moviename_monthlysales = (TextView) itemView.findViewById(R.id.tv_moviename_monthlysales);// 电影名
            tv_releasetime_monthlysales = (TextView) itemView.findViewById(R.id.tv_releasetime_monthlysales);// 上映时间
            tv_days_monthlysales = (TextView) itemView.findViewById(R.id.tv_days_monthlysales);// 上映天数
            tv_boxoffice_monthlysales = (TextView) itemView.findViewById(R.id.tv_boxoffice_monthlysales);// 票房总计
        }
    }
}
